class Solution(object):
    def findPairs(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: int
        """
        n = len(nums)
        now_set = set()
        out_set = set()
        for i in range(n):
            if nums[i] - k in now_set:
                out_set.add((nums[i] - k, nums[i]))
            if nums[i] + k in now_set:
                out_set.add((nums[i], nums[i] + k))
            now_set.add(nums[i])
        return len(out_set)


data = Solution()
nums = [1, 2, 4, 4, 3, 3, 0, 9, 2, 3]
k = 3
print(data.findPairs(nums, k))
